// Copyright (c) 2023 CHANGLEI. All rights reserved.

import 'package:flutter/services.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:tverify/src/tverify_method_channel.dart';
import 'package:tverify/src/ui_decorator.dart';

/// 模板
abstract class TverifyPlatform extends PlatformInterface {
  /// Constructs a TverifyPlatform.
  TverifyPlatform() : super(token: _token);

  static final Object _token = Object();

  static TverifyPlatform _instance = MethodChannelTverify();

  /// The default instance of [TverifyPlatform] to use.
  ///
  /// Defaults to [MethodChannelTverify].
  static TverifyPlatform get instance => _instance;

  /// Platform-specific implementations should set this with their own
  /// platform-specific class that extends [TverifyPlatform] when
  /// they register themselves.
  static set instance(TverifyPlatform instance) {
    PlatformInterface.verifyToken(instance, _token);
    _instance = instance;
  }

  /// 初始化
  Future<void> initLogin(String appId) {
    throw UnimplementedError('initLogin() has not been implemented.');
  }

  /// 预登录
  Future<Map<String, dynamic>?> preLogin() {
    throw UnimplementedError('preLogin() has not been implemented.');
  }

  /// 登录
  /// model: Android请使用[UIConfig]，iOS请使用[UIModel]
  Future<Map<String, dynamic>?> login(UIDecorator decorator) {
    throw UnimplementedError('login() has not been implemented.');
  }

  /// networkType 类型NSString
  /// 值 == 0.无网络; 1.数据流量; 2.wifi; 3.数据+wifi
  /// carrier 类型NSNumber
  /// 值 == 0.未知(未插sim卡，其它运营商等); 1.中国移动mobile;2.中国联通unicom;3.中国电信telecom
  /// iOS only
  Future<Map<String, dynamic>?> getSimInfo() {
    throw UnimplementedError('getSimInfo() has not been implemented.');
  }

  /// 删除取号缓存数据 + 重置网络开关（自定义按钮事件里dimiss授权界面需调用）
  Future<bool?> deleteScrip() {
    throw UnimplementedError('deleteScrip() has not been implemented.');
  }

  /// 设置超时
  /// 设置取号、授权请求和本机号码校验请求时的超时时间，开发者不配置时，默认所有请求的超时时间都为8000，单位毫秒
  Future<void> setTimeout(Duration duration) {
    throw UnimplementedError('setTimeout() has not been implemented.');
  }

  /// 关闭授权界面
  Future<void> dismissLogin([bool animated = true]) {
    throw UnimplementedError('dismissLogin() has not been implemented.');
  }

  /// 获取网络类型，Android only
  Future<String?> getNetworkType() {
    throw UnimplementedError('getNetworkType() has not been implemented.');
  }

  /// 获取网络类型，Android only
  Future<String?> getOperatorType() {
    throw UnimplementedError('getOperatorType() has not been implemented.');
  }

  /// 验证手机号，Android only
  Future<void> certificationNumber(String number) {
    throw UnimplementedError('certificationNumber() has not been implemented.');
  }

  /// 设置debug模式，Android only
  Future<void> setDebugModel(bool isDebug) {
    throw UnimplementedError('setDebugModel() has not been implemented.');
  }

  /// 设置登录按钮文字，Android only
  Future<void> setLoginBtn(String text) {
    throw UnimplementedError('setLoginBtn() has not been implemented.');
  }

  /// 设置是否回调，Android only
  Future<void> setSecondPrivacyCallback(bool isCallback) {
    throw UnimplementedError('setSecondPrivacyCallback() has not been implemented.');
  }

  /// checkbox选中事件，Android only
  void addCheckboxCheckedListener(ValueChanged<Map<String, dynamic>?> callback) {
    throw UnimplementedError('addCheckboxCheckedListener() has not been implemented.');
  }

  /// 点击登录按钮，Android only
  void addLoginClickCompleteListener(ValueChanged<Map<String, dynamic>?> callback) {
    throw UnimplementedError('addLoginClickCompleteListener() has not been implemented.');
  }

  /// 开始点击登录按钮，Android only
  void addLoginClickStartListener(ValueChanged<Map<String, dynamic>?> callback) {
    throw UnimplementedError('addLoginClickStartListener() has not been implemented.');
  }

  /// checkbox选中事件变更，Android only
  void addCheckboxCheckedChangeListener(ValueChanged<bool> callback) {
    throw UnimplementedError('addCheckboxCheckedChangeListener() has not been implemented.');
  }

  /// 授权登录，Android only
  void addAuthLoginListener(VoidCallback callback) {
    throw UnimplementedError('addAuthLoginListener() has not been implemented.');
  }

  /// 点击返回按钮，Android only
  void addPressBackListener(VoidCallback callback) {
    throw UnimplementedError('addPressBackListener() has not been implemented.');
  }

  /// checkbox选中事件，Android only
  void removeCheckboxCheckedListener(ValueChanged<Map<String, dynamic>?> callback) {
    throw UnimplementedError('addCheckboxCheckedListener() has not been implemented.');
  }

  /// 点击登录按钮，Android only
  void removeLoginClickCompleteListener(ValueChanged<Map<String, dynamic>?> callback) {
    throw UnimplementedError('addLoginClickCompleteListener() has not been implemented.');
  }

  /// 开始点击登录按钮，Android only
  void removeLoginClickStartListener(ValueChanged<Map<String, dynamic>?> callback) {
    throw UnimplementedError('addLoginClickStartListener() has not been implemented.');
  }

  /// checkbox选中事件变更，Android only
  void removeCheckboxCheckedChangeListener(ValueChanged<bool> callback) {
    throw UnimplementedError('addCheckboxCheckedChangeListener() has not been implemented.');
  }

  /// 授权登录，Android only
  void removeAuthLoginListener(VoidCallback callback) {
    throw UnimplementedError('addAuthLoginListener() has not been implemented.');
  }

  /// 点击返回按钮，Android only
  void removePressBackListener(VoidCallback callback) {
    throw UnimplementedError('addPressBackListener() has not been implemented.');
  }
}
